<template>
  <div class="hd history">
   
    <search-bar :menu="menu" :showsearch="false" :activeitem="activeitem"></search-bar>
    <position style="padding:12px;width:auto;">
      <router-link to="/cloud">云诊室</router-link>
      &gt;
      <span class="last">我的档案</span>
    </position>

    <div class="tablebox">
      <el-table :data="tableData" style="width: 100%" :show-header="false" @row-click="todetail">
        <el-table-column prop="illName" label="病情"></el-table-column>
        <el-table-column prop="regDeptName" label="科室"></el-table-column>
        <el-table-column prop="orgFullName" label="医院名称"></el-table-column>
        <el-table-column prop="workDate" label="时间"></el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
  import SearchBar from '../../components/SearchBar'
  import Position from '../../components/Position'
  import {CLOUD_MENU, commonAjax, PLATFORM_PREFIX} from '../../api/api'
  export default {
    components: {SearchBar, Position},
    data () {
      return {
        menu: CLOUD_MENU,
        activeitem: 4,
        tableData: [],
        person: JSON.parse(localStorage.person)
      }
    },
    mounted () {
      this.getfilelist()
    },
    methods: {
      getfilelist () {
        commonAjax(
          [this.person.mpiId, 2],
          `${PLATFORM_PREFIX}.registrationService`,
          'getCloudArchives'
        ).then(res => {
          if (res.data.code === 200) {
            this.tableData = []
            for (let i = 0; i < res.data.body.length; i++) {
              for (let j = 0; j < res.data.body[i].cloudRecord.length; j++) {
                this.tableData.push(res.data.body[i].cloudRecord[j])
              }
            }
          } else {
            console.log(res.data.msg)
          }
        }).catch(res => {
          alert('out of service')
        })
      },
      todetail (row, event, column) {
        console.log(JSON.stringify(row))
        this.$router.push({
          path: '/cloud/paper',
          query: {
            regPwd: row.regPwd,
            workDate: row.workDate,
            regDeptName: row.regDeptName
          }
        })
      }
    }
  }
</script>

<style scoped>
  .tablebox{
    padding:0 20px 20px 20px;
    background-color: white;
  }
</style>
